package com.deluxelx.soul.inn.web.file;

import com.deluxelx.soul.inn.bean.file.FileUploadParam;
import com.deluxelx.soul.inn.common.result.SoulInnResult;
import com.deluxelx.soul.inn.service.file.FileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 文件操作-Controller类
 *
 * @author liaozihao
 * @date 2024-04-30 8:44
 */
@RestController
@RequestMapping("/soul/inn/file")
public class FileController {

    @Resource
    private FileService fileService;

    @PostMapping("/upload")
    public SoulInnResult<Boolean> uploadFile(MultipartFile file, @RequestBody FileUploadParam param) {
        Boolean isSuccess = fileService.upload(file, param);
        if (isSuccess) {
            return SoulInnResult.success(Boolean.TRUE);
        }
        return SoulInnResult.fail("文件上传失败");
    }

}
